package models

import (
	"el/bootstrap/driver"
	"time"
)

type AdminUsers struct {
	Id        uint64    `gorm:"column:id" db:"id" json:"id" form:"id"`
	Username  string    `gorm:"column:username" db:"username" json:"username" form:"username"`
	Password  string    `gorm:"column:password" db:"password" json:"password" form:"password"` //密码
	Name      string    `gorm:"column:name" db:"name" json:"name" form:"name"`                 //昵称
	CreatedAt time.Time `gorm:"column:created_at" db:"created_at" json:"created_at" form:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at" db:"updated_at" json:"updated_at" form:"updated_at"`
}

func (my *AdminUsers) InfoByUsername() error {
	return driver.Grom.Where("username = ?", my.Username).First(my).Error
}

func (my *AdminUsers) InfoById() error {
	return driver.Grom.Where("id = ?", my.Id).First(my).Error
}

func NewAdminUser() *AdminUsers {
	return &AdminUsers{}
}
